home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d10 / ps1410.arc / CAL2.BAS < prev    next >
BASIC Source File  |  1990-10-31  |  71KB  |  1,945 lines

  1.     '=========================================================================
  2.     ' Personal Calendar (PC) Program
  3.     '  Copyright (c) 1985-1990, Paul Munoz-Colman.  All Rights Reserved.
  4.     '    Version 14.10
  5.     '     31 Oct 1990
  6.     '    Shareware $25
  7.     '=========================================================================
  8.     '              DOS File CAL2.BAS
  9.     '  Independently Compiled Subprogram Which Is Linked With CAL1.BAS
  10.     '=========================================================================
  11.     '  Written For IBM PCs & Compatibles Under MS DOS 3.30 on a Northgate 486
  12.     '   Compiled By Microsoft Professional BASIC 7.10, Linker Version 5.10
  13.     '=========================================================================
  14.     '  Note -- Tabs in the source file are in positions 6,11,16,21,26,...
  15.     '=========================================================================
  16.     ' $INCLUDE: 'cal1.bi'
  17.     '=========================================================================
  18.     '  Only Subprogram in this File
  19.     '   (compiled WITHOUT error handling--no /E or /X)
  20.     '-------------------------------------------------------------------------
  21.     '    Name                          Purpose
  22.     '    ---------------------------   ---------------------------------------
  23.     '    MainSub                       Main Procedure
  24.     '=========================================================================
  25.     SUB MainSub (MainEntryPoint)  STATIC
  26.     '=========================================================================
  27.     DEFINT A-Z
  28.         SubnumSave = Subnum
  29.         Subnum = 1
  30.     '=========================================================================
  31.     '  This Procedure Exits ONLY Through a Trapped Error and Always Returns
  32.     '   (except in primitive mode, which ends in the main program)
  33.     '=========================================================================
  34.     IF MainEntryPoint = 2 THEN GOTO StartupScreenExit
  35.     '=========================================================================
  36.     IF MainEntryPoint = 3 THEN GOTO MainMenuEntry
  37.     '=========================================================================
  38.     '  MainEntryPoint = 1 is the Startup Entry -- below
  39.     '=========================================================================
  40.     '  Initialize required variables for primitive state
  41.     '-----------------------------------------------------------
  42.     N0 = 0                        ' Variables instead of constants
  43.     N1 = 1                        '  save program size and stack space
  44.     N2 = 2                        '  big time !!
  45.     N3 = 3                        '  These are the most frequently used.
  46.     N4 = 4
  47.     N5 = 5
  48.     N6 = 6
  49.     N7 = 7
  50.     N8 = 8
  51.     N9 = 9
  52.     N10 = 10
  53.     N11 = 11
  54.     N12 = 12
  55.     N13 = 13
  56.     N14 = 14
  57.     N15 = 15
  58.     N16 = 16
  59.     N17 = 17
  60.     N18 = 18
  61.     N19 = 19
  62.     N20 = 20
  63.     N21 = 21
  64.     N22 = 22
  65.     N23 = 23
  66.     N24 = 24
  67.     N25 = 25
  68.     N26 = 26
  69.     N27 = 27
  70.     N28 = 28
  71.     N29 = 29
  72.     N30 = 30
  73.     N32 = 32
  74.     N34 = 34
  75.     N38 = 38
  76.     N39 = 39
  77.     N40 = 40
  78.     N42 = 42
  79.     N43 = 43
  80.     N45 = 45
  81.     N48 = 48
  82.     N49 = 49
  83.     N50 = 50
  84.     N52 = 52
  85.     N53 = 53
  86.     N54 = 54
  87.     N58 = 58
  88.     N60 = 60
  89.     N62 = 62
  90.     N63 = 63
  91.     N64 = 64
  92.     N68 = 68
  93.     N70 = 70
  94.     N71 = 71
  95.     N72 = 72
  96.     N74 = 74
  97.     N75 = 75
  98.     N80 = 80
  99.     N99 = 99
  100.     Nm1 = -1
  101.     Nm2 = -2
  102.     Nm3 = -3
  103.     Blank0$ = ""                    ' Null String
  104.     Blank1$ = " "                    ' 1 Blank Space
  105.     Blank2$ = SPACE$(2)                ' 2 Blank Spaces
  106.     Blank3$ = SPACE$(3)                ' 3 Blank Spaces
  107.     Blank4$ = SPACE$(4)                ' 4 Blank Spaces
  108.     Blank8$ = SPACE$(8)                ' 8 Blank Spaces
  109.     Blank12$ = SPACE$(12)            ' 12 Blank Spaces
  110.     Blank80$ = SPACE$(80)            ' 80 Blank Spaces
  111.     Hyphen$  = "-"
  112.     False$    = "n"                ' Logical No
  113.     Zeroo$ = "0"
  114.     No        =  N0                ' Numeric No
  115.     Noo$        = "No"
  116.     True$    = "y"                ' Logical Yes
  117.     Yess$    = "Yes"
  118.     Yes        = Nm1                    ' Numeric Yes
  119.     WindowInitted = No                ' Window Manager Initialization
  120.     ErrMsgPlacement = 5
  121.     PrimitiveState = Yes
  122.     '=========================================================================
  123.     '  Assign File Numbers for I/O
  124.     FilenumAppt = N1                      ' File number of Appointment File
  125.     FilenumApptSort = N2                  ' File number of Appointment Sort File
  126.     FilenumAuto = N3                      ' File number of Automatic Start File
  127.     FilenumCopy = N4                      ' File number of ASCII Copy File
  128.     FilenumDOS = N5                       ' File number of DOS Command File
  129.     FilenumError = N6                     ' File number of Error Message File
  130.     FilenumExcl = N7                      ' File number of History Exclude File
  131.     FilenumFig = N8                       ' File number of Color Choice File
  132.     FilenumHelp = N9                      ' File number of Help Text File
  133.     FilenumInit = N10                ' File number of Program Init File
  134.     FilenumMusic = N11                 ' File number of Music Choice File
  135.     FilenumNewAppt = N12               ' File number of New Appt File
  136.     FilenumOverdue = N13            ' File number of Overdue Events (.clv)
  137.     FilenumRes = N14                   ' File number of Stay-Res Option File
  138.     FilenumSer = N15                ' File number of Registration Data
  139.     '-------------------------------------------------------------------------
  140.     CALL MhDver(DOSMajorVersion%, DOSMinorVersion%)   ' Get DOS Version
  141.     IF DOSMajorVersion < N3 THEN            'Get DOS Version
  142.         DOS2x = Yes                    'TSR features disabled if not
  143.       ELSE                            ' 3.0 or later
  144.         DOS2x = No
  145.     END IF
  146.     '=========================================================================
  147.     '  Stay-Res Initialization -- Part 1 of 2
  148.     '=========================================================================
  149.     IF NOT DOS2x THEN                    'See if program already in 
  150.         CALL StayResInitialization(N0)    ' memory, if so pop up, if not,
  151.     END IF                            ' terminate this copy
  152.     '=========================================================================
  153.     Insrt% = -2
  154.     PriorInsert = -2
  155.     ScreenPage = N0                ' Set calendar screen page
  156.     HardSnooze = Yes                ' Don't allow Snooze interruption
  157.     CALL VideoMonitorType             ' Determine Color or Monochrome
  158.     IF ColorCRT THEN                ' Set Color Defaults
  159.         Cl1f = N1        ' Blue    on Whi    Events               (1) and (8)
  160.         Cl1b = N7
  161.         Cl2f = N4        ' Red    on Whi    Notes                (2) and (9)
  162.         Cl2b = N7
  163.         Cl3f = N9        ' BrBlu    on blk    Clocks             (3) and (10)
  164.         Cl4f = N3        ' Cyan    on blk    Calendars            (4) and (11)
  165.         Cl5f = N15    ' BrWhi    on blu    Menus               (5) and (12)
  166.         Cl5b = N1
  167.         Cl6f = N2        ' Grn     on blk    Instructions         (6) and (13)
  168.         Chf = N15        ' BrWhi     on blk    Emphasis             (7) and (14)
  169.       ELSE
  170.         Cl1f = N7      '  Monochrome Settings
  171.         Cl2f = N7
  172.         Cl3f = N7
  173.         Cl4f = N7
  174.         Cl5f = N7
  175.         Cl6f = N7
  176.         Chf = 14
  177.         Cif = N7
  178.         Cib = 8
  179.     END IF
  180.     '-------------------------------------------------------------------------
  181.     '  Change the Cursor Shape Depending Upon Insert Mode
  182.     '    Insert On is normal DOS Cursor; Overstrike is Full Solid Cursor
  183.     '  The mono display adapter has lines 0 to 13, the color has 0 to 7
  184.     '   in the LOCATE statement for the cursor size
  185.     OverstrikeCursorStart = N0
  186.     IF MonoCRT THEN
  187.         InsertCursorStart = 12             ' Mono Cursor Defaults
  188.         CursorStop = 13
  189.       ELSE
  190.         InsertCursorStart = N6              ' Color Cursor Defaults
  191.         CursorStop = N7
  192.     END IF
  193.     CursorStart = InsertCursorStart
  194.     CursorState = N0
  195.     '-------------------------------------------------------------------------
  196.     CALL SaveDOSKeyState               ' Save DOS keys and page
  197.     UserSaved = No                    ' Reset user screen saved flag
  198.     CALL SetVideoMode(N0)            ' Change to Text Mode if not there
  199.     CALL SetVideoPage(N0)            ' Change to Page Zero if not there
  200.     '=========================================================================
  201.     CALL Kolors(N6)
  202.     CLS
  203.     CALL BoxDraw(N2, N11, N15, N15, N64)
  204.     Tag$ = " Please Wait--Personal Calendar is Initializing "
  205.     CALL ShowIt(N17, N13, Nm2, Tag$)
  206.     '-------------------------------------------------------------------------
  207.     NewGuy = Yes
  208.     IF ColorCRT THEN
  209.         CALL ReadCalfig                    ' Read (or write) Color Choices
  210.     END IF
  211.     '=========================================================================
  212.     MemoryResident = No                ' Set non-zero once resident first time
  213.     NumberofHotFKeys = 10
  214.     NumberofHotCKeys = 16
  215.     CALL ReadCalinit(N1)            ' Fixed Array Initialization
  216.     CALL SaveCurrentDirectory(N1)      ' Get Calendar Directory
  217.     '=========================================================================
  218.     '  Stay Res Initialization -- Part 2 of 2
  219.     '=========================================================================
  220.     '   This reads the CALRES.DAT file and sets all early options
  221.     IF NOT DOS2x THEN
  222.         CALL StayResInitialization(N1)
  223.     END IF
  224.     '=========================================================================
  225.     '   Initialize Remaining Variables
  226.     '=========================================================================
  227.     '  Debugging Mode If Desired
  228.     IF InString(COMMAND$, "DEBUG") THEN
  229.         DebugRequested = Yes
  230.       ELSE
  231.         DebugRequested = No
  232.     END IF
  233.     AllowInsertMode = No
  234.     DateFromDOS$ = DATE$
  235.     TodaysDate$ = MID$(DateFromDOS$, N7, 4) + MID$(DateFromDOS$, N1, N2) + _
  236.                 MID$(DateFromDOS$, 4, N2)
  237.     '=========================================================================
  238.     AlarmMusicPlayed = Yes
  239.     AlarmSet = No
  240.     ApptFile = No
  241.     ApptFilename$ = Blank8$
  242.     AutoMode$ = False$
  243.     Bsp = 8
  244.     CalendarColumns(N1) = N1
  245.     CalendarColumns(N2) = 25
  246.     CalendarColumns(N3) = 49
  247.     CalendarDate$ = TodaysDate$
  248.     CalendarStartRow = 8
  249.     CapsHold = N0
  250.     ClockPositionGraphic$ = CHR$(176)    ' Dark-Screened Whole Character (░)
  251.     ClockScreen = No
  252.     ClockScreenPrint = No
  253.     ClockSeparatorGraphic$ = CHR$(178) ' Light-Screened Whole Character (▓)
  254.     Column1 = N1                             ' Columns for Clock Screen
  255.     Column2 = 26                            '  Instructions
  256.     Column3 = 46
  257.     Column4 = 67
  258.     CopyFilename$ = Blank12$
  259.     CurrentEvent = N1
  260.     CurrentEventLine$ = Blank80$
  261.     CurrentNote = N1
  262.     CurrentNoteHist = N1
  263.     CursorColumn = N1
  264.     CursorRow = N1
  265.     Del = 83
  266.     DesiredCalendars$ = TodaysDate$
  267.     DirectReturn = No
  268.     DownArrow$ = CHR$(25)                        ' Down-Arrow Character
  269.     EarlyPopDownFailed = No
  270.     East = 77
  271.     EchoSuppression = No
  272.     EditPagesize = 20
  273.     EndKey = 79
  274.     Enter = 13
  275.     ErrorMessageToWrite = No
  276.     Esc = 27
  277.     EventDate$ = SPACE$(8)
  278.     EventTime$ = SPACE$(4)
  279.     EventDateTime$ = SPACE$(12)
  280.     EventPageCounter = N0
  281.     EventSizeCode$ = "e"                         '  Default 60 Events
  282.     EventTableSize = 60                          ' Default Number of Events
  283.     EventTableStable = No
  284.     EventYear$ = SPACE$(N2)            ' Fix sizes of these variables
  285.     EventMonth$ = EventYear$            ' so MhMidString can be used without
  286.     EventDay$ = EventYear$            ' reassigning them later
  287.     EventHour$ = EventYear$
  288.     EventMinute$ = EventYear$
  289.     EventLimRepeat$ = EventYear$
  290.     EventRepeat$ = SPACE$(N3)
  291.     EventYear1st2$ = EventYear$
  292.     EventText$ = SPACE$(53)
  293.     EventtoHistory = Yes
  294.     F1 = 59
  295.     F2 = 60
  296.     F3 = 61
  297.     F4 = 62
  298.     F5 = 63
  299.     F6 = 64
  300.     F7 = 65
  301.     FirstTimeClock = Yes
  302.     FirstTimeExecuted = Yes
  303.     FooterAction$ = Blank1$
  304.     FooterRecall = No
  305.     FooterSize = 5
  306.     ForceDate = No
  307.     HighestValue# = 999999999999#        ' High Long Value
  308.     HomeKey = 71
  309.     InclHistory = No
  310.     InclNotes = Yes
  311.     InHelp = No
  312.     InMenu = No
  313.     Ins = 82
  314.     InterruptedLoop = No
  315.     KeyCursor = 4                                ' KeyStuff Functions
  316.     KeyCursorOff = -4
  317.     KeyDelayedExit = No
  318.     KeyNumOn = 5
  319.     KeyNumOff = N6
  320.     KeyShiftTrap = N0
  321.     KeyStatus = N1
  322.     KeyStatusAbs = 8
  323.     KeySingle = N2
  324.     KeyTimerInit = N7
  325.     KeyTrapEnabled = No
  326.     KeyWait = N3
  327.     LeftArrow$ = CHR$(27)                        ' West-Arrow Character
  328.     LimSep$ = Blank1$
  329.     LoopCounterShow = Yes
  330.     MainMenuAuto = 10
  331.     MainMenuClock = N2
  332.     MainMenuColor = 13
  333.     MainMenuCopy = N7
  334.     MainMenuCreate = 4
  335.     MainMenuDate = 11
  336.     MainMenuDelete = 5
  337.     MainMenuDOS = 12
  338.     MainMenuHelp = 9
  339.     MainMenuList = N3
  340.     MainMenuOptions = 8
  341.     MainMenuPrint = N6
  342.     MainMenuRow = N7
  343.     MainMenuUse = N1                              ' Main Menu Values
  344.     MenuCancelled = N1                            ' Menu Exit from ESC Key
  345.     MenuEntryChosen = N0                          ' Menu Exit from Enter Key
  346.     MenuNormalExit = N0                           ' Menu Exit from Enter Key
  347.     MenuRecursiveReturn = No
  348.     MenuRow = N7
  349.     MenuSize = N0
  350.     MenuSpecialExit = N0                 ' Menu Exit other than Escape
  351.     MovingClockTick$ = CHR$(4)             ' Diamond ()
  352.     NoHistEndDefault = No
  353.     NormalCalendars = Yes
  354.     North = 72
  355.     NoteSize = N2
  356.     NoteSizeCode$ = "e"                          ' Default 60 Notes
  357.     NullEvent$ = "         -  -         :" + SPACE$(57)
  358.     'Null Event
  359.     NullEventOld$ = "      -  -           :" + SPACE$(58)
  360.     NumberofEvents = EventTableSize
  361.     NumberofNotes = 60
  362.     NumHold = N0
  363.     OldNumberEvents = NumberofEvents
  364.     OldNumberNotes = NumberofNotes
  365.     OnEditPage = No
  366.     OnScreen = No
  367.     OtherCalendars = No
  368.     OverdueCount = N0
  369.     OverduePosition = N1
  370.     PathLegalChars$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890(){}@#$%^&!-_'~.\"
  371.     PathLegalLength = LEN(PathLegalChars$)
  372.     Pending = 5
  373.     PgDn = 81
  374.     PgUp = 73
  375.     PopWait = No
  376.     PopWaitHold = No
  377.     PrecursorChime$ = "mb o3 mn t55 l6"
  378.     PrintedEventsScheduled = Nm1
  379.     PrinterLineCount = 1
  380.     PrinterLineLimit = 0
  381.     PrinterPause$ = False$
  382.     PrintingReport = No
  383.     PrintorCopy$ = "p"
  384.     Prnt = 42
  385.     RedisplayNotesEvents = Yes
  386.     Rescheduling = No
  387.     ReturnMessage$ = Blank0$
  388.     RightArrow$ = CHR$(26)                       ' East-Arrow Character
  389.     ScreenSize = 20
  390.     ScrollingCalendars = No
  391.     SoundLevel = 4
  392.     South = N80
  393.     SpecialExitAllowed = N1             ' Menu Special Exits Allowed
  394.     SpecialExitDelete = N2              ' Menu Delete Key For Item Delete
  395.     SpecialExitDisallowed = N0          ' Menu Special Exits Not Allowed
  396.     SpecialExitEndKey = N7              ' Menu End Key For Last Page
  397.     SpecialExitF2 = 5                  ' Menu F2 For Event Resequencing
  398.     SpecialExitHomeKey = N6             ' Menu Home Key For 1st Page
  399.     SpecialExitInsert = N1              ' Menu Insert Key For Item Insertion
  400.     SpecialExitPgDn = 4                ' Menu Page Up For Previous Page
  401.     SpecialExitPgUp = N3                ' Menu Page Down For Next Page
  402.     StartingHistory = N2 + NumberofEvents + NumberofNotes   'Default 12
  403.     StartingNote = N2 + NumberofEvents                        'Default 62
  404.     StartupScreen = Yes
  405.     StartupScreenHold = StartupScreen
  406.     Tabb = 9
  407.     TextSize = LEN(EventText$)
  408.     UpArrow$ = CHR$(24)                          ' Up-Arrow Character
  409.     ValidSizes$ = "cdefghijklmnopq"                   ' 20 to 300 size codes
  410.     WarningSet = No
  411.     WeekBreak$ = True$
  412.     WeekendScheduling$ = False$
  413.     West = 75
  414.     WhichColor = N0
  415.     WhichEvent = N1
  416.     ZeroLine = Strng$(N80, N0)
  417.     '=========================================================================
  418.     CALL ReadCalinit(N2)                ' Fixed Array Initialization
  419.     '-------------------------------------------------------------------------
  420.     '  Set Printer Array to None Selected
  421.     PrinterCodes(1) = -99
  422.     '=========================================================================
  423.     '  Set Printer Default
  424.     '=========================================================================
  425.     AvailablePrinters$ = "EIP4-"   ' Epson, IBM, HPIIP/III, IBM4019, None
  426.     SelectedPrinter$ = "-"        ' Default to no initialization
  427.     '=========================================================================
  428.     FatalError = Yes
  429.     PrimitiveState = No
  430.     '=========================================================================
  431.     '   Greeting Screens
  432.     '=========================================================================
  433.     CALL ClearScreenNormal(N0)
  434.     '=========================================================================
  435.     '   Enable Exiting Keys (Ctrl-Break and Ctrl-Esc)
  436.     '=========================================================================
  437.     ExitKeys = Yes
  438.     '=========================================================================
  439.     '    Greeting Screen 1
  440.     '=========================================================================
  441.     CALL ReadCalser                ' Get User Validation
  442.     CALL GenGreetingScreen1            ' Display Startup Screen
  443.     CALL KeyStuff(KeyStatusAbs)        ' Display CAPS/NUML State First Time
  444.     HardSnooze = No                ' Allow keystroke-interrupted
  445.     CALL Snooze(5!)                ' Sleep for 5 seconds
  446. StartupScreenExit:
  447.     StartupScreen = No
  448.     StartupScreenHold = StartupScreen  ' In case 1st popped down right away
  449.     '=========================================================================
  450.     CALL ReadCalauto                   ' Read (or write) Auto Startup File
  451.     '-------------------------------------------------------------------------
  452.     ' If User wants to be forced to set date & time
  453.     IF ForceDate THEN
  454.         CALL SetDateTime
  455.     END IF
  456.     '=========================================================================
  457.     '    Greeting Screen 2
  458.     '=========================================================================
  459.     CALL ClearScreenNormal(N1)
  460.     CALL GenerateGreeting(N2)
  461.     CALL DisplayApptFilename           ' And Show Filename If It Exists
  462.     '-------------------------------------------------------------------------
  463.     ' Done Here So Greeting Is First
  464.     IF (NewGuy = Yes OR UpdatingCalfig = Yes) AND ColorCRT THEN
  465.         UpdatingCalfig = No
  466.         CALL Snooze(0.7!)
  467.         CALL PrepareforMessage
  468.         CALL ShowIt(N0, N0, N0, _
  469.             " Created/Updated Color Choice File CALFIG.DAT")
  470.     END IF
  471.     '-------------------------------------------------------------------------
  472.     IF NewGuy OR UpdatingCalres THEN
  473.         CALL Snooze(0.7!)
  474.         CALL PrepareforMessage
  475.         CALL ShowIt(N0, N0, N0, _
  476.             " Created Memory-Resident Choice File CALRES.DAT")
  477.     END IF
  478.     '-------------------------------------------------------------------------
  479.     IF UpdatingCalauto THEN
  480.         CALL Snooze(0.7!)
  481.         CALL PrepareforMessage
  482.         CALL ShowIt(N0, N0, N0,_
  483.             " Created/Updated Automatic Startup File CALAUTO.DAT")
  484.         UpdatingCalauto = No
  485.     END IF
  486.     '=========================================================================
  487.     CALL ReadCalmusic                  ' Get Music Choices or Set Them
  488.     '=========================================================================
  489.     CALL ReadCalexcl                   ' Get History Exclusions or Set Them
  490.     '=========================================================================
  491.     CALL ReadCalDOS                    ' Get Prestored DOS Command or Set It
  492.     '=========================================================================
  493.     '   Test For Automatic Startup
  494.     '         (Automatic Startup is Cancelled By an Early TSR Error)
  495.     AutoStarted = No
  496.     IF AutostartMode THEN
  497.         AutoStarted = Yes
  498.         Tag$ = " Please Wait -- "
  499.         CALL ShowIt(N13, N11, Nm2, Tag$)
  500.         Tag$ = " Automatic Startup Is In Progress "
  501.         CALL ShowIt(N0, Nm2, Nm2, Tag$)
  502.         IF SrAutoPopDown AND NOT SrAutoPopDownHappened THEN
  503.             Tag$ = " ... and Automatic Pop Down Has Been Requested "
  504.             CALL ShowIt(N0, - N3, Nm2, Tag$)
  505.         END IF
  506.     END IF
  507.     IF MonoCRT THEN
  508.         MainMenuLastEntry = 13
  509.       ELSE
  510.         MainMenuLastEntry = 14
  511.     END IF
  512.     '=========================================================================
  513.     '   Get Rid of CALTODAY.DAT File If There (Not Used Any More)
  514.     Tag$ = "caltoday.dat"
  515.     CALL KillAFile(Tag$)
  516.     '-------------------------------------------------------------------------
  517.     GOSUB TodaysDateSet
  518.     GOTO MainMenuEntry
  519.     '-------------------------------------------------------------------------
  520.     '     Today's Day Of Week, Date, and Time (Referenced After SetDateTime)
  521. TodaysDateSet:
  522.     TodaysDate$ = MID$(DATE$, N7, 4) + MID$(DATE$, N1, N2) + _
  523.         MID$(DATE$, 4, N2)
  524.     CALL DayDate(TodaysDate$)
  525.     TodaysDay = IndexedDay
  526.     CurrentTime$ = MID$(TIME$, N1, N2) + MID$(TIME$, 4, N2) + _
  527.         MID$(TIME$, N7, N2)
  528.     CurrentDateTime$ = TodaysDate$ + MID$(CurrentTime$, N1, 4)
  529.     CurrentDateTime# = VAL(CurrentDateTime$)
  530.     RETURN
  531.     '=========================================================================
  532.     '   Main Menu Entry
  533.     '=========================================================================
  534. MainMenuEntry:
  535.     PrintingReport = No
  536.     OnEditPage = No
  537.     '-------------------------------------------------------------------------
  538.     '    This Clears the Screen
  539.     IF ErrorMessageToWrite THEN                  ' All Error Messages Are
  540.                                         '  Shown Here Just Before
  541.         CALL PrepareforFatal                    '  Return to Main Menu
  542.         CALL ShowIt(N0, ErrMsgPlacement, N0, ErrorLine1$)
  543.         CALL ShowIt(N0, Nm1, N0, ErrorLine2$) 
  544.     END IF
  545.     '-------------------------------------------------------------------------
  546.     IF NOT FirstTimeExecuted OR ErrorMessageToWrite THEN
  547.         ErrorMessageToWrite = No
  548.       ELSE
  549.         FirstTimeExecuted = No
  550.     END IF
  551.     '-------------------------------------------------------------------------
  552.     IF NewGuy THEN    'New User -- Wait 5-6 seconds, then go to help
  553.         Tag$ = " Hello, new user.  Help is on the way! -- "
  554.         CALL ShowIt(N15, N15, Nm2, Tag$)
  555.         CALL PlayStuff(Alarm$)
  556.         ErrorSwitch = No
  557.         CALL KeyStuff(KeyStatus)
  558.         CALL Snooze(2.5!)
  559.         CALL BlankFatal                    ' Kill Message after 2.5 seconds
  560.         CALL Snooze(3!)
  561.         GOTO HelpEntry                     ' Go to Help after 5.5 seconds
  562.     END IF
  563.     CreatingFile = No
  564.     '-------------------------------------------------------------------------
  565.     '     ApptFile Says Whether An Appointment File Is Open
  566.     IF NOT EventTableStable THEN
  567.         CALL CloseFiles
  568.     END IF
  569.     IF NOT AutoStarted THEN
  570.         '--------------------------------------------------------------------
  571.         '  Menu Handler Uses MenuLines$ Array For Choice Lines, Maximum 20
  572.         '--------------------------------------------------------------------
  573.         MenuLines(N1) = "Use or Change an Existing Appointment File"
  574.         MenuLines(N2) = "Clock and Calendar Alone"
  575.         MenuLines(N3) = "Display a List of Saved Appointment Files"
  576.         MenuLines(4) = "Create a New Appointment File"
  577.         MenuLines(5) = "Delete Appointment File"
  578.         MenuLines(N6) = "Print Appointment File"
  579.         MenuLines(N7) = "Copy Appointments to an ASCII DOS File"
  580.         MenuLines(8) = "Options for Appointment File"
  581.         MenuLines(9) = "Help"
  582.         IF NOT DOS2x THEN
  583.             MenuLines(10) = _
  584.                 "Memory-Resident (TSR Mode) Options and Automatic Startup"
  585.           ELSE
  586.             MenuLines(10) = "Automatic Startup"
  587.         END IF
  588.         MenuLines(11) = "Change DOS Date and Time"
  589.         MenuLines(12) = "DOS Session or Command"
  590.         MenuLines(13) = "Color Choices"        ' Not On Monochrome Menu
  591.         '  Because On Monochrome, This Entry Overlays the Color Choice Entry
  592.         MenuLines(MainMenuLastEntry) = "Direct to the Clock Screen"
  593.     END IF
  594.     '-------------------------------------------------------------------------
  595.     '     If Monochrome, No Color Change Choice
  596.     '     If Not Returning To Menu From Other Screens, Last Choice Suppressed
  597.     IF DirectReturn AND ApptFilename$ = Blank8$ THEN
  598.         DirectReturn = No
  599.         Menu1 = MainMenuUse
  600.     END IF
  601.     IF DirectReturn THEN
  602.         MenuSize = MainMenuLastEntry
  603.       ELSE
  604.         MenuSize = MainMenuLastEntry - N1
  605.     END IF
  606.     RedisplayCalendars = Yes
  607.     IF AutoStarted THEN
  608.         '--------------------------------------------------------------------
  609.         IF ApptFilename$ <> Blank8$ THEN
  610.             MenuChoice = MainMenuLastEntry    ' Auto Start With File
  611.             Menu1 = MainMenuLastEntry
  612.             GOTO AppointmentExistCheck
  613.           ELSE
  614.             MenuChoice = N2                     ' Auto Start Without File
  615.             Menu1 = MainMenuClock
  616.             AutoStarted = No
  617.             GOTO ProcessMenuChoice
  618.         END IF
  619.     END IF
  620.     MainMenuRow = N7
  621.     GOSUB ClearFilenamePass
  622.     GOTO GreetingShow
  623.     '-------------------------------------------------------------------------
  624.     '   Clear File Name and Password off Screen Before Menu is Generated
  625. ClearFilenamePass:
  626.     CALL ShowMult(N6, N23, N1, N39, N2)
  627.     RETURN
  628.     '-------------------------------------------------------------------------
  629. GreetingShow:
  630.     CALL GenerateGreeting(N3)      ' Top of Main Menu Screen (3 line version)
  631.     CALL ReturnLine
  632.     CALL QuitLine
  633.     IF NOT DOS2x THEN CALL PopLine
  634.     CALL MenuDriver(MenuSize, Menu1, MainMenuRow, Nm1, No, N0, N0, N1)
  635.     CALL ReturnLineDelete
  636.     CALL QuitLineDelete
  637.     IF NOT DOS2x THEN CALL PopLineDelete
  638.     IF MenuExit = MenuCancelled THEN CALL EndItAll
  639.     CALL BlankFatal
  640.     '-------------------------------------------------------------------------
  641.     '   Process Menu Choice
  642.     '-------------------------------------------------------------------------
  643. ProcessMenuChoice:
  644.     SELECT CASE Menu1
  645.         CASE MainMenuUse, MainMenuCreate TO MainMenuOptions   ' Opens File
  646.             GOTO StartAppointment
  647.         CASE MainMenuClock
  648.             GOTO ClockInitialize          ' 2 = Clock/Calendar Only
  649.         CASE MainMenuList
  650.             CALL FileList                 ' 3 = Display Appointment Files
  651.         CASE MainMenuHelp
  652. HelpEntry:
  653.             CALL Help                     ' 9 = Help
  654.             IF NewGuy THEN
  655.                 Menu1 = MainMenuCreate        ' Set New Ones To Create
  656.                 NewGuy = No
  657.             END IF
  658.         CASE MainMenuAuto
  659.             CALL AutoStart           '10 = Automatic Startup
  660.         CASE MainMenuDate
  661.             CALL SetDateTime              '11 = Change DOS Date/Time
  662.             GOSUB TodaysDateSet              '    and Associated Parameters
  663.         CASE MainMenuDOS                   '12 = DOS Session
  664.             CALL DOSShell(N0)              '    and Return
  665.         CASE 13, 14                        '13/14 = Color Choices / Return
  666.             '  Set Colors
  667.             IF ColorCRT THEN
  668.                 IF Menu1 = MainMenuLastEntry - N1 THEN
  669.                     CALL SetColors
  670.                     GOTO MainMenuEntry
  671.                 END IF
  672.             END IF
  673.             '  Direct Return
  674.             IF Menu1 = MainMenuLastEntry AND EventTableStable THEN
  675.                 GOTO EventEditStart
  676.             END IF
  677.             IF Menu1 = MainMenuLastEntry THEN 
  678.                 GOTO AppointmentExistCheck 
  679.               ELSE 
  680.                 GOTO StartAppointment
  681.             END IF
  682.     END SELECT
  683.     GOTO MainMenuEntry
  684.     '-------------------------------------------------------------------------
  685.     '   All Functions That Request Access To Appointment File Start Here
  686.     '    (Functions  1,    4,       5,     6,    7,     8
  687.     '               Use, Create, Delete, Print, Copy, Options)
  688.     '-------------------------------------------------------------------------
  689.     ' Skip File Name/Password Stuff If Already In Use
  690.     '    6 (Print), 7 (Copy), 8 (Options)
  691. StartAppointment:
  692.     IF (Menu1 <= MainMenuDelete OR Menu1 >= MainMenuHelp) OR _
  693.         NOT DirectReturn         THEN
  694.         TimerSave! = TIMER
  695.         InputResponse$ = ApptFilename$
  696.         Tag$ = "Appointment File Name"
  697.         CALL ControlledInput(N23, N28, N23, N5, N8, Tag$, _
  698.             InputResponse$, N0, N1, N1, N1)
  699.         IF Keystroke$ = CHR$(Esc) THEN
  700.             CALL ClearScreenNormal(N1)
  701.             AutoStarted = No
  702.             GOTO MainMenuEntry
  703.         END IF
  704.         IF ApptFilename$ <> InputResponse$ THEN
  705.             EventTableStable = No
  706.             CALL CloseFiles
  707.         END IF
  708.         ApptFilename$ = InputResponse$
  709.         IF ApptFilename$ = Blank8$ THEN
  710.             CALL FileList
  711.             AutoStarted = No
  712.             GOTO MainMenuEntry
  713.         END IF
  714.     END IF
  715.     '=========================================================================
  716.     '   Open Appointment File, New Or Otherwise
  717. AppointmentExistCheck:
  718.     IF EventTableStable AND Menu1 <> MainMenuCreate THEN GOTO OptionsProcessing
  719.     '-------------------------------------------------------------------------
  720.     '  See if it is there
  721.     ApptExists = FileExist(ApptFilename$ + ".cld")
  722.     '=========================================================================
  723.     '     If Existing On Create, A Mistake
  724.     '     If Not Exists On Use, A Mistake
  725.     IF Menu1 <> MainMenuCreate AND ApptExists THEN
  726.         '     Open as Random and Proceed
  727.         CALL OpenAppts           '  Exists On Non-Create, Okay
  728.         EventTableStable = No
  729.         ApptFileStatus$ = "o"
  730.         GOTO OptionsProcessing
  731.     END IF
  732.     '-------------------------------------------------------------------------
  733.     IF Menu1 = MainMenuCreate AND NOT ApptExists THEN
  734.         GOTO ReplaceFile                     '  Absent On Create, Okay
  735.     END IF
  736.     '=========================================================================
  737.     '   Menu for Exists On Create or Non Exists On Use
  738.     DirectReturn = No
  739.     EventTableStable = No
  740.     OnEditPage = No
  741.     CALL MajorBeeper
  742.     CALL ClearScreenNormal(N1)
  743.     IF Menu1 <> MainMenuCreate THEN
  744.         ScreenTitles$(N1) = "Non-Existent Appointment File"
  745.       ELSE
  746.         ScreenTitles$(N1) = "Appointment File Already Exists"
  747.     END IF
  748.     CALL Titles(N1)
  749.     MenuLines(N1) = "Enter The File Name Again"
  750.     MenuLines(N2) = "Display A List Of Saved Appointment Files"
  751.     IF Menu1 <> MainMenuCreate THEN
  752.         MenuLines(N3) = "Create A New Appointment File"
  753.       ELSE
  754.         MenuLines(N3) = _
  755.             "Wipe Out Existing Appointment File And Create New One"
  756.     END IF
  757.     IF Menu1 = MainMenuDelete THEN MenuSize = N2 ELSE MenuSize = N3
  758.     CALL MenuDriver(MenuSize, Menu2, MainMenuRow, Nm1, No, N0, N1, N1)
  759.     CreatingFile = No
  760.     CALL BlankFatal
  761.     IF MenuExit = MenuCancelled THEN
  762.         CALL ClearScreenNormal(N1)
  763.         AutoStarted = No
  764.         GOTO MainMenuEntry
  765.     END IF
  766.     SELECT CASE Menu2
  767.         CASE 1                        '  Enter Name Again
  768.             GOTO StartAppointment
  769.         CASE 2
  770.             CALL FileList            '  List of Existing Files
  771.             GOTO MainMenuEntry
  772.         CASE 3
  773. ReplaceFile:
  774.             IF Menu1 = MainMenuCreate THEN
  775.                 CLOSE
  776.                 Tag$ = ApptFilename$ + ".cld"
  777.                 CALL KillAFile(Tag$)
  778.             END IF
  779.             CALL OpenAppts          '  Create A New Appointment File
  780.             CreatingFile = Yes       '   or Wiping Out Old And Creating New
  781.             ApptFileStatus$ = False$
  782.             DirectReturn = Yes
  783.             GOTO PasswordProcessing
  784.     END SELECT
  785.     '-------------------------------------------------------------------------
  786.     'File Format: 1  Master record with password and options
  787.     '                Master record controls size of --
  788.     '   Default  60  Event records (NumberofEvents)
  789.     '   Default  60  Note records  (NumberofNotes)  <-- pointed to
  790.     '                                                      By StartingNote
  791.     '     unlimited  History records       <-- pointed to by StartingHistory
  792. OptionsProcessing:
  793.     DirectReturn = Yes
  794.     '    Get Options
  795.     CALL GetOptions
  796.     '  Be Extra Careful On File Deletion, Clobber Previous Password
  797.     IF Menu1 = MainMenuDelete THEN
  798.         EnteredPassword$ = Blank8$
  799.         GOTO PasswordProcessing
  800.     END IF
  801.     '  No Password on Repeats
  802.     IF Menu1 > MainMenuDelete AND Menu1 < MainMenuHelp AND _
  803.        ApptFilename$ <> Blank8$ AND _
  804.        ApptPassword$ = EnteredPassword$ AND DirectReturn THEN 
  805.         GOTO PasswordCheck
  806.     END IF
  807.     IF EnteredPassword$ <> ApptPassword$ THEN GOTO PasswordProcessing
  808.     IF Menu1 = MainMenuLastEntry OR ApptPassword$ = Blank8$ THEN 
  809.         GOTO PasswordCheck
  810.     END IF
  811.     '=========================================================================
  812.     '   Appointment File Password
  813. PasswordProcessing:
  814.     FOR I = N1 TO N2
  815.             IF I = N2 AND NOT CreatingFile THEN GOTO ApptFirstWrite
  816.             IF I = N2 THEN
  817.                 CALL PrepareforMessage
  818.                 Tag$ = "Re-Enter Password To Confirm, Please"
  819.                 CALL ShowIt(N0, N0, N0, Tag$)
  820.             END IF
  821.         InputResponse$ = Blank8$
  822.         EchoSuppression = Yes
  823.         IF NOT CreatingFile THEN
  824.             CALL ScreenBottoms
  825.           ELSE
  826.             CALL ReturnLine
  827.             CALL QuitLine
  828.         END IF
  829.         Tag$ = "Appointment File Password"
  830.         CALL ControlledInput(N24, N28, N24, N1, N8, Tag$, InputResponse$, _
  831.             N0, N1, N0, N1)
  832.         CALL ScreenBottomsDelete
  833.         EchoSuppression = No
  834.         IF Keystroke$ = CHR$(Esc) AND NOT CreatingFile THEN
  835.             CALL ClearScreenNormal(N1)
  836.             AutoStarted = No
  837.             GOTO MainMenuEntry
  838.         END IF
  839.         IF I = N1 THEN PasswordHold$ = InputResponse$
  840.     NEXT I
  841.     IF PasswordHold$ <> InputResponse$ THEN
  842.         CALL MajorBeeper
  843.         CALL Kolors(N14)
  844.         CALL BlankError
  845.         Tag$ = "Password Confirmation Doesn't Match -- Try Again"
  846.         CALL ShowIt(N0, N0, N0, Tag$)
  847.         GOTO PasswordProcessing
  848.     END IF
  849. ApptFirstWrite:
  850.     CreatingFile = No
  851.     CALL Kolors(N6)
  852.     CALL BlankFatal
  853.     EnteredPassword$ = InputResponse$
  854.     IF ApptFileStatus$ <> "o" THEN
  855.         '           If Not Old, Make New
  856.         '====================================================================
  857.         '   New File, Clear Space For Master Record
  858.         ApptPassword$ = EnteredPassword$
  859.         '           New Password
  860.         CALL SetOptions
  861.         '           Set Options
  862.         ExitKeys = No
  863.         CALL MhLset (ApptBuffer$, Blank80$)
  864.         EventTableStable = No
  865.         FOR I = N1 TO NumberofEvents
  866.             CALL KeyStuff(KeyStatus)
  867.             Var = N1 + I
  868.             CALL PutApptRecord(Var)
  869.         NEXT I
  870.         FOR I = N1 TO NumberofNotes
  871.             CALL KeyStuff(KeyStatus)
  872.             Pointer = NumberofEvents + N1 + I
  873.             CALL PutApptRecord(Pointer)
  874.         NEXT I
  875.         ExitKeys = Yes
  876.         ApptFileStatus$ = "o"
  877.       ELSE
  878.         '===============================================================
  879.         '   Password Check
  880. PasswordCheck:
  881.         IF EnteredPassword$ <> ApptPassword$ THEN
  882.             '           Check Password, Delete File Or Read Table
  883.             DirectReturn = No
  884.             CALL PrepareforError
  885.             Tag$ = "Password Invalid"
  886.             CALL ShowIt(N0, N0, N0, Tag$)
  887.             AutoStarted = No
  888.             GOTO MainMenuEntry
  889.         END IF
  890.     END IF
  891.     '=========================================================================
  892.     '   Read Events
  893.     '=========================================================================
  894.     CALL ShowMult(N6, N23, N1, N40, N2)     'Clear File Name and Password Lines
  895.     '   Delete File and Options Doesn't Need To Read Events (Wastes Time)
  896.     IF Menu1 <> MainMenuOptions THEN
  897.         IF Menu1 <> MainMenuDelete THEN
  898.             IF NOT EventTableStable THEN
  899.                 '    WhichEvent         Current Event Number
  900.                 '    EventPageCounter  Current Event Page (0 to n)
  901.                 '    ApptBuffer$        File Buffer
  902.                 WhichEvent = N1
  903.                 EventPageCounter = N0
  904.                 CALL SetArrays           '  Event/Note Array (re)set
  905.                 CALL SequenceEventsTable
  906.             END IF
  907.           ELSE
  908.             '---------------------------------------------------------------
  909.             '   Delete File
  910.             CALL CloseFiles
  911.             Tag$ = ApptFilename$ + ".cld"
  912.             CALL KillAFile(Tag$)
  913.             OnEditPage = No
  914.             CALL ClearScreenNormal(N1)
  915.             CALL PrepareforMessage
  916.             Tag$ = "File " + ApptFilename$ + " Successfully Deleted"
  917.             CALL ShowIt(N0, N0, N0, Tag$)
  918.             DirectReturn = No
  919.             EventTableStable = No
  920.             TimerSave! = TIMER
  921.             ApptFilename$ = Blank8$
  922.             GOTO MainMenuEntry
  923.         END IF
  924.         '====================================================================
  925.         '   Print or Copy File
  926.         PrintorCopy$ = False$
  927.         IF Menu1 = MainMenuPrint OR Menu1 = MainMenuCopy THEN
  928.             '  Print File or Copy to DOS File
  929.             IF Menu1 = MainMenuPrint THEN
  930.                 PrintorCopy$ = "p"
  931.               ELSE
  932.                 PrintorCopy$ = "w"
  933.             END IF
  934.             CALL PrintCopy
  935.             GOTO MainMenuEntry
  936.         END IF
  937.       ELSE
  938.         '   Process Options
  939.         CALL Options
  940.         GOTO MainMenuEntry
  941.     END IF
  942.     '   Options
  943.     IF Menu1 <> MainMenuLastEntry THEN
  944.         '====================================================================
  945.         '   Opened File, Choice of Clock/Event/Note/History Displays
  946.         MenuLines(N1) = MenuLines(MainMenuLastEntry)
  947.         MenuLines(N2) = "Event Editing"
  948.         MenuLines(N3) = "Note Editing"
  949.         MenuLines(4) = "History Editing"
  950.         OnEditPage = No
  951.         CALL ClearScreenNormal(N1)
  952.         ScreenTitles$(N1) = "Appointment File Usage"
  953.         CALL Titles(N1)
  954.         CALL MenuDriver(N4, MenuEditing, N6, Nm1, No, N0, N1, N1)
  955.         IF MenuExit = MenuCancelled THEN
  956.             CALL ClearScreenNormal(N1)
  957.             Menu1 = MainMenuUse
  958.             GOTO MainMenuEntry
  959.         END IF
  960.         SELECT CASE MenuEditing
  961.             CASE 1
  962.                 Menu1 = MainMenuLastEntry
  963.             CASE 2
  964.             CASE 3, 4
  965.                 IF MenuEditing = 3 THEN
  966.                     Tag$ = "N"
  967.                   ELSE
  968.                     Tag$ = "H"
  969.                 END IF
  970.                 CALL NotesHistory(Tag$)
  971.         END SELECT
  972.     END IF
  973.     '=========================================================================
  974.     '   Start Event Editing, Fill One-Screen Menu Array
  975.     '=========================================================================
  976. EventEditStart:
  977.     OnEditPage = No
  978.     MenuSingleLine = No
  979.     ResequenceEvents = No
  980.     RedisplayNotesEvents = Yes
  981.     IF Menu1 = MainMenuLastEntry THEN 
  982.         GOTO EventOverdueCleared
  983.     END IF
  984. EventMenuFill:
  985.     WhichEventSave = WhichEvent
  986.     FOR JJ = N1 TO EditPagesize
  987.         WhichEvent = JJ + EventPageCounter * EditPagesize
  988.         CALL ApptToMenu(N1)
  989.         MenuLines(JJ) = CurrentEventLine$
  990.     NEXT JJ
  991.     WhichEvent = WhichEventSave
  992.     '           Event Editing, Sort If Changed
  993.     IF OnScreen THEN
  994.         Label1$ = STR$(N1 + EventPageCounter * EditPagesize)
  995.         Label2$ = STR$((EventPageCounter + N1) * EditPagesize)
  996.         Label$ = "(" + RIGHT$(Label1$, LEN(Label1$) - N1) + Hyphen$ + _
  997.             RIGHT$(Label2$, LEN(Label2$) - N1) + ")"
  998.         IF FooterSize >= N6 THEN CALL ShowIt(N3, F5HelpRow, N1, Blank8$)
  999.         CALL ShowIt(N3, N17, N1, Blank80$)              ' Clear Row Above Edit
  1000.         CALL ShowIt(N13, N0, N0, Label$)                ' Print Event Label
  1001.     END IF
  1002. EventScreen:
  1003.     IF NOT OnScreen OR OnScreenFirst THEN
  1004.         IF NOT MenuSingleLine AND NOT OnScreen THEN
  1005.             '---------------------------------------------------------------
  1006.             '   Display Event Editing Full Screen
  1007.             CALL Kolors(N5)
  1008.             TimerDisplaySuppress = Yes
  1009.             CLS
  1010.             OnEditPage = Yes
  1011.             CALL Kolors(N19)
  1012.             Tag$ = "Repeat   Date   Day Time   " + _
  1013.                 "Event        (Page " + RIGHT$(STR$(EventPageCounter + _
  1014.                 N1), N2) + " Of " + RIGHT$(STR$(NumberofEvents \ N20), _
  1015.                 N2) + ")" + SPACE$(N25)
  1016.             CALL ShowIt(N0, N1, N1, Tag$)
  1017.         END IF
  1018.         FOR I = N1 TO N3
  1019.             CALL ShowIt(N14, N21 + I, N1, EventInstructions1(I))
  1020.         NEXT
  1021.         FOR I = N1 TO N3
  1022.             CALL ShowIt(N9, N21 + I, N28, EventInstructions2(I))
  1023.         NEXT
  1024.         CALL ShowIt(N0, N25, N1, EventInstructions3)
  1025.         FOR I = N1 TO N3
  1026.             CALL ShowIt(N19, N21 + I, N50, EventNoteSharedIns(I))
  1027.         NEXT
  1028.         OnScreenFirst = No
  1029.     END IF
  1030.     '-------------------------------------------------------------------------
  1031.     '   Accept Event Editing Choice
  1032.     '-------------------------------------------------------------------------
  1033. EventMenuExit:
  1034.     MenuSpecialExit = SpecialExitAllowed'Allow Special Functions
  1035.     MenuEventEditing = WhichEvent - (EditPagesize * EventPageCounter)
  1036.     IF NOT OnScreen THEN MenuRow = N1 ELSE MenuRow = 17
  1037.     EditingEvents = Yes
  1038.     CALL MenuDriver(EditPagesize, MenuEventEditing, MenuRow, N0, _
  1039.         MenuSingleLine, MenuSpecialExit, N0, N0)
  1040.     EditingEvents = No
  1041.     WhichEvent = (EditPagesize * EventPageCounter) + MenuEventEditing
  1042.     MenuSingleLine = Yes
  1043.     '           Accept Choice
  1044.     SELECT CASE MenuSpecialExit
  1045.         CASE MenuNormalExit
  1046.             GOTO EventMenuCancel
  1047.         CASE SpecialExitF2
  1048.             IF ResequenceEvents THEN
  1049.                 GOTO EventMenuOut
  1050.               ELSE
  1051.                 GOTO EventMenuError
  1052.             END IF
  1053.         CASE SpecialExitDelete
  1054.             '   Delete Event
  1055.             EventRepeat$ = "X  "
  1056.             ResequenceEvents = Yes
  1057.             GOTO InDone
  1058.         CASE SpecialExitPgUp
  1059.             IF EventPageCounter = N0 THEN
  1060.                 GOTO EventMenuError
  1061.               ELSE
  1062.                 EventPageCounter = EventPageCounter - N1
  1063.             END IF
  1064.         CASE SpecialExitPgDn
  1065.             IF EventPageCounter = (NumberofEvents \ EditPagesize - N1) THEN
  1066.                 GOTO EventMenuError
  1067.               ELSE
  1068.                 EventPageCounter = EventPageCounter + N1
  1069.             END IF
  1070.         CASE SpecialExitHomeKey
  1071.             IF EventPageCounter = N0 THEN
  1072.                 GOTO EventMenuError
  1073.               ELSE
  1074.                 EventPageCounter = N0
  1075.             END IF
  1076.         CASE SpecialExitEndKey
  1077.             IF EventPageCounter = (NumberofEvents \ EditPagesize - N1) THEN
  1078.                 GOTO EventMenuError
  1079.               ELSE
  1080.                 EventPageCounter = NumberofEvents \ EditPagesize - N1
  1081.             END IF
  1082.         CASE ELSE
  1083.             '           Error, Try Again
  1084. EventMenuError:
  1085.             CALL MinorBeeper
  1086.             GOTO EventMenuExit
  1087.     END SELECT
  1088.     '=========================================================================
  1089.     '  Reset Page Size and Event Number and Continue
  1090.     WhichEvent = (EditPagesize * EventPageCounter) + N1
  1091.     MenuSingleLine = No
  1092.     GOTO EventMenuFill
  1093.     '-------------------------------------------------------------------------
  1094.     '   Cancel From Event Editing Resequences By Date/Time If Changed
  1095.     '-------------------------------------------------------------------------
  1096. EventMenuCancel:
  1097.     IF MenuExit = MenuCancelled THEN
  1098. EventMenuOut:
  1099.         MenuSingleLine = No
  1100.         CALL ClearOverdueTable
  1101.         '  Esc Sort Events
  1102. EventOverdueCleared:
  1103.         IF ResequenceEvents OR OnScreen THEN
  1104.             IF NOT OnScreen THEN
  1105.                 CALL Kolors(N5)
  1106.                 ClearLimit = 4
  1107.               ELSE
  1108.                 ClearLimit = 8
  1109.                 Tag$ = SPACE$(N9)
  1110.                 CALL ShowIt(N3, N17, N1, Tag$)
  1111.             END IF
  1112.             ScreenMultRow = 26 - ClearLimit
  1113.             CALL ShowMult(N0, ScreenMultRow, N1, N80, ClearLimit)
  1114.         END IF
  1115.         '    (Re)Sequence Events
  1116.         CALL SequenceEventsTable
  1117.         '           Display Calendar Flag
  1118.         IF ResequenceEvents THEN RedisplayCalendars = Yes
  1119.         '           Resequence In Place From F2
  1120.         IF MenuSpecialExit = SpecialExitF2 THEN
  1121.             WhichEvent = N1
  1122.             EventPageCounter = N0
  1123.             OnScreenFirst = Yes
  1124.             GOTO EventEditStart
  1125.         END IF
  1126.         '   Reprint Bottom of Screen Instructions
  1127.         '   On Screen Returns Right To Clock Loop
  1128.         IF OnScreen THEN
  1129.             RefreshInstructions = Yes
  1130.             GOTO TimingLoopStart
  1131.         END IF
  1132.         CurrentEvent = N1
  1133.         '   Off Screen Displays Whole Clock Page
  1134.         GOTO ClockInitialize
  1135.     END IF
  1136.     '=========================================================================
  1137.     '   Event An Event Line--Provide Instructions
  1138.     '=========================================================================
  1139.     CALL ApptToMenu(N1)                '           Split Variables
  1140.     '   Bottom of Page Editing Instructions for ControlledInput
  1141.     FOR I = N1 TO 4
  1142.         CALL ShowIt(N14, N21 + I, N34, EventInput(I))
  1143.     NEXT
  1144.     '=========================================================================
  1145.     '   Edit An Event Line--Process Each Field
  1146. EventFields:
  1147.     ResequenceEvents = Yes
  1148.     OnScreenFirst = Yes
  1149.     IF NOT OnScreen THEN
  1150.         BoxRow = MenuEventEditing + N1
  1151.       ELSE
  1152.         BoxRow = MenuEventEditing + 17
  1153.     END IF
  1154.     '-------------------------------------------------------------------------
  1155.     '     Before Editing, Write Previous (Non-Null) Record To History
  1156.     IF CurrentEventLine$ <> Blank80$ AND _
  1157.        CurrentEventLine$ <> NullEvent$ THEN
  1158.         EventtoHistory = Yes
  1159.         HistoryBuffer$ = CurrentEventLine$
  1160.         CALL WritetoHistory
  1161.     END IF
  1162.     '           To History
  1163.     '-------------------------------------------------------------------------
  1164.     '(Bi/Multi)Weekly/Daily/Monthly/Quarterly/Yearly Indicators (EventRepeat$)
  1165. FieldRepeat:
  1166.     WhichEventField = N1
  1167.     GOSUB InstructionFill
  1168.     GOTO RepeatIn
  1169.     '    Display Whatever Edit Instructions are Appropriate
  1170.     '     Along With Any Returned Error Message
  1171. InstructionFill:
  1172.     FOR I = N1 TO 4
  1173.         CALL ShowIt(N13, (N21 + I), N1, (EditInstructions(WhichEventField, I)))
  1174.     NEXT I
  1175.     CALL EventErrorMessage
  1176.     RETURN
  1177.     '
  1178. RepeatIn:
  1179.     CALL ControlledInput(BoxRow, N4, N1, N1, N3, Blank0$, EventRepeat$, _
  1180.         N0, N0, N0, N0)
  1181.     ON InString(CHR$(Tabb) + CHR$(Esc) + CHR$(F1) + CHR$(Enter), _
  1182.         RIGHT$(Keystroke$, N1)) GOTO FieldText, InDone, InDone, FieldLimRep
  1183.     '-------------------------------------------------------------------------
  1184.     '     Limited-Repeat Indicator (EventLimRepeat$) Only Shows
  1185.     '       If EventRepeat$ Has Something
  1186. FieldLimRep:
  1187.     IF EventRepeat$ = SPACE$(N3) THEN
  1188.         EventLimRepeat$ = SPACE$(N2)
  1189.       ELSE
  1190.         '  Skip if Null
  1191.         WhichEventField = 8
  1192.         GOSUB InstructionFill 'Instructions
  1193.         CALL ControlledInput(BoxRow, N1, N1, N1, N2, Blank0$, _
  1194.             EventLimRepeat$, N1, N0, N0, N0)
  1195.     END IF
  1196.     ON InString(CHR$(Tabb) + CHR$(Esc) + CHR$(F1) + CHR$(Enter), _
  1197.         RIGHT$(Keystroke$, N1)) GOTO FieldRepeat, InDone, InDone, FieldMonth
  1198.     '-------------------------------------------------------------------------
  1199.     '     Month (EventMonth$)
  1200. FieldMonth:
  1201.     WhichEventField = N2
  1202.     GOSUB InstructionFill 'Instructions
  1203.     CALL ControlledInput(BoxRow, N8, N1, N1, N2, Blank0$, EventMonth$, _
  1204.         N1, N0, N0, N0)
  1205.     ON InString(CHR$(Tabb) + CHR$(Esc) + CHR$(F1) + CHR$(Enter), _
  1206.         RIGHT$(Keystroke$, N1)) GOTO FieldLimRep, InDone, InDone, FieldDay
  1207.     '-------------------------------------------------------------------------
  1208.     '     Day (EventDay$)
  1209. FieldDay:
  1210.     WhichEventField = 4
  1211.     GOSUB InstructionFill 'Instructions
  1212.     CALL ControlledInput(BoxRow, N11, N1, N1, N2, Blank0$, EventDay$, _
  1213.         N1, N0, N0, N0)
  1214.     ON InString(CHR$(Tabb) + CHR$(Esc) + CHR$(F1) + CHR$(Enter), _
  1215.         RIGHT$(Keystroke$, N1)) GOTO FieldMonth, InDone, InDone, FieldYear
  1216.     '-------------------------------------------------------------------------
  1217.     '     Year (EventYear$)
  1218. FieldYear:
  1219.     WhichEventField = 5
  1220.     GOSUB InstructionFill 'Instructions
  1221.     CALL ControlledInput(BoxRow, N14, N1, N1, N2, Blank0$, EventYear$, _
  1222.         N1, N0, N0, N0)
  1223.     IF EventYear$ = SPACE$(N2) THEN
  1224.         EventYear1st2$ = SPACE$(N2)
  1225.       ELSE
  1226.         '   First Two Digits of Year is Dependent on DOS Date
  1227.         '    Next Century if Last Two Is Before Last Two In DOS Date
  1228.         '    This Century if Last Two Is Equal/More Than Last Two In DOS Date
  1229.         '   (So the program doesn't have to be changed if it lives that long!)
  1230.         IF VAL(EventYear$) < VAL(MID$(TodaysDate$, N3, N2)) THEN
  1231.             EventYear1st2$ = RIGHT$(STR$(VAL(MID$(TodaysDate$, N1, N2)) _
  1232.                             + N1), N2)
  1233.           ELSE
  1234.             EventYear1st2$ = MID$(TodaysDate$, N1, N2)
  1235.         END IF
  1236.     END IF
  1237.     ON InString(CHR$(Tabb) + CHR$(Esc) + CHR$(F1) + CHR$(Enter), _
  1238.         RIGHT$(Keystroke$, N1)) GOTO FieldDay, InDone, InDone, FieldHour
  1239.     '-------------------------------------------------------------------------
  1240.     '     Hour (EventHour$)
  1241. FieldHour:
  1242.     WhichEventField = N6
  1243.     GOSUB InstructionFill 'Instructions
  1244.     CALL ControlledInput(BoxRow, N21, N1, N1, N2, Blank0$, EventHour$, _
  1245.         N1, N0, N0, N0)
  1246.     ON InString(CHR$(Tabb) + CHR$(Esc) + CHR$(F1) + CHR$(Enter), _
  1247.         RIGHT$(Keystroke$, N1)) GOTO FieldYear, InDone, InDone, FieldMinute
  1248.     '-------------------------------------------------------------------------
  1249.     '     Minute (EventMinute$)
  1250. FieldMinute:
  1251.     WhichEventField = N7
  1252.     GOSUB InstructionFill 'Instructions
  1253.     CALL ControlledInput(BoxRow, N24, N1, N1, N2, Blank0$, EventMinute$, _
  1254.                      N1, N0, N0, N0)
  1255.     ON InString(CHR$(Tabb) + CHR$(Esc) + CHR$(F1) + CHR$(Enter), _
  1256.         RIGHT$(Keystroke$, N1)) GOTO FieldHour, InDone, InDone, FieldText
  1257.     '-------------------------------------------------------------------------
  1258.     '     Text (EventText$)
  1259. FieldText:
  1260.     WhichEventField = N3
  1261.     GOSUB InstructionFill 'Instructions
  1262.     CALL ControlledInput(BoxRow, N28, N1, N1, TextSize, Blank0$, _
  1263.                      EventText$, N0, N0, N0, N1)
  1264.     ON InString(CHR$(Tabb) + CHR$(Esc) + CHR$(F1) + CHR$(Enter), _
  1265.         RIGHT$(Keystroke$, N1)) GOTO FieldMinute, InDone, InDone, FieldRepeat
  1266.     GOTO FieldRepeat
  1267.     '=========================================================================
  1268.     '   Accept Change, Check The Date/Time And Redisplay The Results
  1269.     '=========================================================================
  1270.     '     Combine Date/Time, Check For Validity
  1271. InDone:
  1272.     CALL CombineDateTime
  1273.     DateToValidate$ = EventDate$ + EventTime$
  1274.     CALL CheckDate(DateToValidate$)
  1275.     IF DateValidation THEN
  1276.         CALL MajorBeeper
  1277.         GOTO FieldRepeat
  1278.     END IF
  1279. DeleteEvent:
  1280.     CALL ValidateEventDate
  1281.     IF EventValidationError = N1 THEN
  1282.         CALL MajorBeeper
  1283.         GOTO EventFields
  1284.     END IF
  1285.     '-------------------------------------------------------------------------
  1286.     '     Repack Event Array For Menu And Rewrite Record In File
  1287.     CALL RepackApptRecord
  1288.     CALL BuildMenuLine
  1289.     MenuLines(MenuEventEditing) = CurrentEventLine$
  1290.     CALL MhLset (ApptBuffer$, CurrentEventRecord$)
  1291.     Pointer = N1 + WhichEvent
  1292.     CALL PutApptRecord(Pointer)
  1293.     EventTableStable = No
  1294.     GOTO EventScreen
  1295.     '=========================================================================
  1296.     '   Display Clock Display--Displacement Different If File Open
  1297. ClockInitialize:
  1298.     IF Menu1 = MainMenuClock THEN
  1299.         ApptFile = No
  1300.       ELSEIF EventTableStable THEN
  1301.         ApptFile = Yes
  1302.     END IF
  1303.     WholeClock = Yes
  1304.     OnEditPage = No
  1305.     RedisplayCalendars = Yes
  1306.     RefreshInstructions = Yes
  1307.     FromOverduePage = No
  1308.     ClockScreen = Yes
  1309.     ClockRow = N0
  1310.     IF ApptFile THEN
  1311.         ClockColumn = 13
  1312.       ELSE
  1313.         ClockColumn = N7
  1314.     END IF
  1315.     CALL Kolors(N3)
  1316.     TimerDisplaySuppress = Yes
  1317.     CLS
  1318.     CALL KeyStuff(KeyStatusAbs)
  1319.     '  Calendar Offset
  1320.     IF ApptFile THEN
  1321.         CalendarStartColumn = 10
  1322.       ELSE
  1323.         CalendarStartColumn = 5
  1324.     END IF
  1325.     '  Event Display When Reprinting Time
  1326.     IF ApptFile THEN RedisplayNotesEvents = Yes
  1327.     Var1 = CalendarStartRow + N5
  1328.     Var2 = N1 + CalendarStartColumn + CalendarColumns(N2)
  1329.     Tag$ = " (Computing Calendars) "
  1330.     CALL ShowIt(N14, Var1, Var2, Tag$)
  1331.     '-------------------------------------------------------------------------
  1332.     '     Change Condition Of Sound On Display
  1333.     IF ApptFile THEN
  1334.         X5 = N7
  1335.         X6 = N0
  1336.       ELSE
  1337.         X5 = 18
  1338.         X6 = N3
  1339.     END IF
  1340.     ScreenMultRow = X5 + N1
  1341.     ScreenColumn = X6 + N1
  1342.     CALL ShowMult(N6, ScreenMultRow, ScreenColumn, N6, N2)
  1343.     CALL ShowIt(N0, ScreenMultRow, N0, "Sound")
  1344.     GOSUB SoundDisplay
  1345.     GOTO FilenameDisplay
  1346. SoundDisplay:
  1347.     CALL ShowIt(N6, (X5 + N2), (X6 + N1), (SoundLevels$(SoundLevel)))
  1348.     RETURN
  1349.     '-------------------------------------------------------------------------
  1350. FilenameDisplay:
  1351.     IF ApptFile THEN
  1352.         '--------------------------------------------------------------------
  1353.         '     Display File Name
  1354.         CALL GetFilenameLength
  1355.         Tag$ = MID$(ApptFilename$, N1, FilenameLength) + "'s"
  1356.         CALL ShowErase(N0, N1, N1, N10, Tag$)
  1357.         Tag$ = "Calendar"
  1358.         CALL ShowErase(N0, N2, N1, N10, Tag$)
  1359.     END IF
  1360.     '--------------------------------------------------------------------
  1361.     '     Display Lines Of Clock
  1362.     FOR ClockLine = N1 TO N7
  1363.         CALL KeyStuff(KeyStatus)
  1364.         ScreenRow = ClockRow + ClockLine
  1365.         ScreenColumn = ClockColumn + N2
  1366.         SELECT CASE ClockLine
  1367.             CASE 1
  1368.                 CALL ShowIt(N10, N0, N0, (ClockGraphics(N1)))
  1369.             CASE 2, 6
  1370.                 CALL ShowIt(N3, N0, N0, (ClockGraphics(N2)))
  1371.             CASE 3 TO 5
  1372.                 CALL ShowIt(N3, N0, N0, (MID$(ClockGraphics(N2), _
  1373.                     N1, N1)))
  1374.                 ScreenColumn = ClockColumn + 64
  1375.                 CALL ShowIt(N0, N0, N0, (MID$(ClockGraphics(N2), _
  1376.                     N1, N1)))
  1377.             CASE 7
  1378.                 CALL ShowIt(N10, N0, N0, (ClockGraphics(N3)))
  1379.         END SELECT
  1380.     NEXT ClockLine
  1381.     '  Display Box around Time, Same Color as Clock Foreground
  1382.     CALL Kolors(N3)
  1383.     CALL BoxDraw(N1, ClockRow% + N3, ClockRow% + N5, ClockColumn% + N4, _
  1384.         ClockColumn% + N62)
  1385.     TimeBlock = Yes
  1386.     '=========================================================================
  1387.     '   BEGINNING OF ONE SECOND TIMING LOOP
  1388.     '=========================================================================
  1389.  
  1390.     '   Update The Time--Hold A Tight Loop Until Time Changes Seconds
  1391.     '    or until a keystroke is made
  1392.     '   Pop up date and time enabled if using appointment file -- only here!!
  1393. TimingLoopStart:
  1394.     IF ApptFile THEN SrPopDateTime = Yes
  1395.     InterruptedLoop = No
  1396.     LoopCounter = N0
  1397.     LoopCounterShow = No
  1398.     DO
  1399.         CurrentTimer$ = TIME$
  1400.         IF DebugRequested THEN
  1401.             LoopCounter = LoopCounter + N1
  1402.         END IF
  1403.         '---------------------------------------------------------------
  1404.         CALL KeyStuff(KeySingle)
  1405.         IF LEN(Keystroke$) > N0 THEN
  1406.             InterruptedLoop = Yes
  1407.             LoopCounterShow = Yes
  1408.             GOTO TimingLoopEnd
  1409.         END IF
  1410.     LOOP WHILE CurrentTimer$ = PreviousTime$
  1411.     LoopCounterShow = Yes
  1412.     PreviousTime$ = CurrentTimer$
  1413.     '-------------------------------------------------------------------------
  1414.     IF ApptFile AND (EventsScheduled <> PrintedEventsScheduled OR _
  1415.                         WholeClock = Yes)                     THEN
  1416.         CALL ShowMult(N6, N4, N1, N9, N3)
  1417.         EventsScheduled$ = LTRIM$(RIGHT$(STR$(EventsScheduled), N3))
  1418.         IF EventsScheduled = N0 THEN EventsScheduled$ = Noo$
  1419.         CALL ShowIt(N6, N4, N2, EventsScheduled$)
  1420.         CALL ShowIt(N0, Nm1, N1, "Event")
  1421.         IF EventsScheduled <> N1 THEN
  1422.             CALL ShowIt(N0, N0, Nm1, "s")
  1423.           ELSE
  1424.             CALL ShowIt(N0, N0, Nm1, Blank1$)
  1425.         END IF
  1426.         CALL ShowIt(N0, Nm1, N1, "Scheduled")
  1427.         PrintedEventsScheduled = EventsScheduled
  1428.     End If
  1429.     '-------------------------------------------------------------------------
  1430.     CALL UpdateClockScreen
  1431.     '=========================================================================
  1432.     '   Sound The Alarm On An Overdue Event--Skip if Neither--Alarm Overrides
  1433.     '=========================================================================
  1434.     '   If Appointment File In Use, Then Check Alarm Table For Overdue Event
  1435.     IF ApptFile AND NOT AlarmSet THEN
  1436.         '--------------------------------------------------------------------
  1437.         '     AlarmSet Is Set If Alarm Is To Ring
  1438.         WarningSet = No
  1439.         '  Reset
  1440.         SrPopTime# = HighestValue#
  1441.         FOR I = N1 TO NumberofEvents
  1442.             IF Alarms(I).Alarm <> 0# AND Alarms(I).Alarm < SrPopTime# THEN
  1443.                 SrPopTime# = Alarms(I).Alarm
  1444.             END IF
  1445.             IF Alarms(I).Warning <> 0# AND _
  1446.                Alarms(I).Warning < SrPopTime#         THEN
  1447.                 SrPopTime# = Alarms(I).Warning
  1448.             END IF
  1449.             IF Pending AND Alarms(I).Warning <> 0# AND _
  1450.                Alarms(I).Warning <= CurrentDateTime#     THEN 
  1451.                 WarningSet = Yes
  1452.             END IF
  1453.             '  Set Warning To Blink
  1454.             IF Alarms(I).Alarm <> 0# AND _
  1455.                Alarms(I).Alarm <= CurrentDateTime#         THEN
  1456.                 AlarmSet = Yes
  1457.             END IF
  1458.         NEXT I
  1459.         IF SrPopTime# <> HighestValue# THEN
  1460.             SrPopDateTime = Yes ' Enable pop
  1461.           ELSE
  1462.             SrPopDateTime = No  ' Else disable
  1463.         END IF
  1464.     END IF
  1465.     IF (AlarmSet OR WarningSet) AND ApptFile THEN
  1466.     '  If Alarm or Warning Was Found On First One, Check All Others Before
  1467.     '   Processing the Alarm
  1468.         IF SrAutoPopDown AND NOT SrAutoPopDownHappened THEN
  1469.             SrAutoPopDownHappened = Yes   ' Kill AutoPop If Alarm or Warning
  1470.         END IF
  1471.         FOR JJ = N1 TO NumberofEvents
  1472.             CALL KeyStuff(KeyStatus)
  1473.             IF Pending AND Alarms(JJ).Warning <> 0# AND _
  1474.                Alarms(JJ).Warning <= CurrentDateTime#     THEN  '  Skip Later
  1475.                 WarningSet = Yes
  1476.                 Alarms(JJ).Warning = 0#
  1477.                 PendingEvents(JJ) = JJ
  1478.             END IF
  1479.             '           Set Warning To Blink
  1480.             IF Alarms(JJ).Alarm <> 0# AND _
  1481.                Alarms(JJ).Alarm <= CurrentDateTime# THEN  ' Later Entry Skip
  1482.                 AlarmMusicPlayed = No
  1483.                 AlarmSet = Yes
  1484.                 ResequenceEvents = Yes
  1485.                 RedisplayNotesEvents = Yes
  1486.             END IF
  1487.             '           Load Alarm
  1488.         NEXT JJ
  1489.         IF AlarmSet THEN WarningSet = No' Alarm Always Takes Precedence
  1490.         '  Play Music
  1491.         IF SoundLevel > N2 THEN CALL PlayAlarmWarning(WarningSet)
  1492.         '   Test for Alarm First
  1493.         IF AlarmSet THEN
  1494.             RedisplayCalendars = Yes ' Alarm May Change Calendars
  1495.             ' Reset Alarm Flag and Resort The Event Table After Alarm Rings
  1496.             AlarmSet = No
  1497.             SrPopDateTime = No       ' Pop up date and time disabled
  1498.             CALL ProcessAlarm
  1499.             IF FromOverduePage THEN 
  1500.                 GOTO ClockInitialize
  1501.             END IF
  1502.           ELSE
  1503.             '  Force Footer Regeneration
  1504.             RedisplayNotesEvents = Yes
  1505.             FooterAction$ = "e"
  1506.         END IF
  1507.     END IF
  1508.     '=========================================================================
  1509.     '   On The Mark, Sound The Chimes
  1510.     IF NOT FirstTimeClock AND ChimeCount <> N0 AND _
  1511.           CurrentMinute MOD 15 = N0 AND SoundLevel = 4     THEN
  1512.         '  Ring Chime
  1513.         IF CurrentMinute THEN
  1514.             PlayString$ = PrecursorChime$ + Strng$(ChimeCount, 67) ' "C"
  1515.           ELSE
  1516.             PlayString$ = Chime$ + PrecursorChime$ + Strng$(ChimeCount, 71)
  1517.         END IF                                            ' "G"
  1518.         CALL PlayStuff(PlayString$)
  1519.         ErrorSwitch = No
  1520.         ChimeCount = N0 ' reset count
  1521.     END IF
  1522.     '=========================================================================
  1523.     '   All Over, Save Date, Timer, Hours, Minutes, Seconds
  1524.     ChimeCount = N0
  1525.     PreviousDate$ = TodaysDate$
  1526.     PreviousHour = CurrentHour
  1527.     PreviousMinute = CurrentMinute
  1528.     PreviousSecond = CurrentSecond
  1529.     PreviousQuarter = CurrentQuarter
  1530.     PrevQuarterPosition = CurrentHourPosition
  1531.     FirstTimeClock = No
  1532.     FooterAction$ = Blank1$
  1533.     IF FooterRecall THEN               'Check Instruction Pop-Back Timer
  1534.         PopTimerNow! = FIX(TIMER)
  1535.         IF PopTimerNow! - PopTimerStart! = 10! THEN
  1536.             RedisplayNotesEvents = Yes
  1537.             RefreshInstructions = Yes
  1538.             FooterRecall = No
  1539.         END IF
  1540.     END IF
  1541.     '=========================================================================
  1542.     '   END OF ONE SECOND TIMING LOOP--ACCEPT A KEYSTROKE
  1543.     '=========================================================================
  1544.     '  Note:  Pop-down is done in Sub KeyStuff, NOT Here!
  1545.     CALL KeyStuff(KeySingle)
  1546.     '           Place Caplock and Numlock on screen if needed
  1547. TimingLoopEnd:
  1548.     AutoStarted = No
  1549.     SELECT CASE (LEN(Keystroke$) + N1)
  1550.         CASE 1                        '  No Keystroke
  1551.             GOTO EndOfKeys
  1552.         CASE 2                        '  Length One Keys
  1553.             GOTO ClockScreenKey
  1554.         CASE 3                        '  Length Two Keys
  1555.             GOTO TwoByteKey
  1556.     END SELECT
  1557.     '=========================================================================
  1558.     '   Length One Keys--Print, Letters, Escape, and Del (Numlocked is .)
  1559.     '                                           and End (Numlocked is 1)
  1560.     '                                           and West (Numlocked is 4)
  1561.     '                                           and East (Numlocked is 6)
  1562.     '                                           and North (Numlocked is 8)
  1563.     '                                           and South (Numlocked is 2)
  1564.     '                                           and PgUp (Numlocked is 9)
  1565.     '                                           and PgDn (Numlocked is 3)
  1566. ClockScreenKey:
  1567.     SELECT CASE InString(CHR$(Prnt) + "AaSsDdEeHhNn.1Tt468293" + CHR$(Esc), _
  1568.         Keystroke$)
  1569.         '--------------------------------------------------------------------
  1570.         CASE 1                        '  Print Appointment File
  1571.             IF NOT ApptFile THEN
  1572.                 GOTO BadKey
  1573.               ELSE
  1574.                 ClockScreenPrint = Yes
  1575.                 PrintorCopy$ = "p"
  1576.                 CALL PrintCopy
  1577.             END IF
  1578.         '--------------------------------------------------------------------
  1579.         CASE 2 TO 5                   '  Set Sound (A or S, Does Not Matter)
  1580.             '  Level  1=Utterly Silent     2=Errors Only
  1581.             '         3=Alarms             4=Chimes (Everything)
  1582.             IF ApptFile THEN
  1583.                 SoundLevel = SoundLevel - N1
  1584.                 IF SoundLevel = N0 THEN SoundLevel = 4
  1585.               ELSE
  1586.                 IF SoundLevel <> 4 THEN SoundLevel = 4 ELSE SoundLevel = N1
  1587.             END IF
  1588.             GOSUB SoundDisplay
  1589.         '--------------------------------------------------------------------
  1590.         CASE 6, 7, 16, 17             '  Calendars
  1591.             '     Display Calendars For Different Date Or Return
  1592.             '         To Today's Calendars
  1593.             '     OtherCalendars$ Tells Which Calendar Footing
  1594.             '---------------------------------------------------------------
  1595. DateSpecific:
  1596.             IF InString("Dd", Keystroke$) = N0 AND _
  1597.                 NOT ScrollingCalendars                 THEN
  1598.             '           Return to Today ("T") Requested
  1599.               IF NormalCalendars THEN GOTO BadKey     '  No Return If There
  1600.                   OtherCalendars = No         '  "D"ate Other
  1601.                   NormalCalendars = Yes            '  Normal Calendars
  1602.                   CalendarDate$ = TodaysDate$
  1603.               ELSE
  1604.             '---------------------------------------------------------------
  1605.             '  Specific Date ("D") or Calendar Scrolling Requested
  1606.                 OtherCalendars = Yes
  1607.                 NormalCalendars = No               '  Other Calendars
  1608.             '---------------------------------------------------------------
  1609.             END IF
  1610.             '---------------------------------------------------------------
  1611.             RedisplayNotesEvents = Yes         '  All Calendars
  1612.             RefreshInstructions = Yes
  1613.             GOSUB HelpPromptKill
  1614.             TimeBlock = Yes
  1615.             IF NOT NormalCalendars AND NOT ScrollingCalendars THEN
  1616.                 GOSUB BottomErase
  1617.                 '----------------------------------------------------------
  1618. GetDate:
  1619.                 RequestedCalendars$ = MID$(CalendarDate$, 5, 4) + _
  1620.                                   MID$(CalendarDate$, 1, 4)
  1621.                 CALL ControlledInput(N25, N50, N25, _
  1622.                     N17, N8, "Enter Desired Date (MMDDYYYY)", _
  1623.                     RequestedCalendars$, N1, N0, N0, N1)
  1624.                 DesiredCalendars$ = MID$(RequestedCalendars$, 5, 4) + _
  1625.                     MID$(RequestedCalendars$, N1, 4)
  1626.                 IF RequestedCalendars$ = Blank8$ THEN
  1627.                     CALL MajorBeeper
  1628.                     GOTO GetDate
  1629.                 END IF
  1630.                 DateToValidate$ = DesiredCalendars$ + SPACE$(4)
  1631.                 CALL CheckDate(DateToValidate$)
  1632.                 IF DateValidation THEN
  1633.                     CALL MajorBeeper
  1634.                     GOTO GetDate
  1635.                 END IF
  1636.             '---------------------------------------------------------------
  1637.                 CalendarDate$ = DesiredCalendars$'Other Calendars
  1638.             END IF
  1639.             '---------------------------------------------------------------
  1640.             '  Normal/Scroll Calendars Comes Here
  1641.             GOSUB BottomErase
  1642.             CALL ShowIt(N14, N25, Nm2, " (Computing) ")
  1643.             CALL PrintCalendar
  1644.             GOTO EndOfKeys
  1645.             '
  1646. BottomErase:
  1647.             CALL Kolors(N3)
  1648.             CALL ClearLast4
  1649.             RETURN
  1650.         '===================================================================
  1651.         CASE 8, 9
  1652.             '  Edit Events (E) (File Open) or Use File (File Closed)
  1653.             ClockScreen = No
  1654.             Menu1 = MainMenuUse
  1655.             RedisplayCalendars = Yes
  1656.             IF ApptFile THEN           ' Appt File Already Open--Edit
  1657.                 EditPagesize = 20
  1658.                 OnScreen = No
  1659.                 OnEditPage = No
  1660.                 WhichEvent = N1
  1661.                 EventPageCounter = N0
  1662.                 GOTO EventEditStart
  1663.             END IF
  1664.             CALL DirectReturnCheck
  1665.             CALL ClearScreenNormal(N1)               'Return to Main Menu
  1666.             GOTO MainMenuEntry
  1667.         '--------------------------------------------------------------------
  1668.         CASE 10, 11                   ' H or h
  1669.             '     Change or View History (H)
  1670.             NotesorHistory$ = "H"
  1671.             GOTO GoNotes
  1672.         '--------------------------------------------------------------------
  1673.         CASE 12, 13
  1674.             '     Change or View Notes (N)
  1675.             NotesorHistory$ = "N"
  1676. GoNotes:
  1677.             IF NOT ApptFile THEN GOTO BadKey
  1678.             EditPagesize = 20
  1679.             OnScreen = No
  1680.             IF NotesorHistory$ = "H" AND _
  1681.                LOF(FilenumAppt) \ N80 < StartingHistory         THEN
  1682.                 GOTO BadKey
  1683.               ELSE
  1684.                 ClockScreen = No
  1685.                 CALL NotesHistory(NotesorHistory$)
  1686.                 GOTO ClockInitialize
  1687.             END IF
  1688.         '--------------------------------------------------------------------
  1689.         CASE 14                       ' . for Delete
  1690.             GOTO DelOverdue
  1691.         '--------------------------------------------------------------------
  1692.         CASE 15                       ' 1 for End
  1693.             GOTO PrinterPage
  1694.         '====================================================================
  1695.         CASE 18, 19                   '  Scrolling Calendars With Arrows
  1696.             '  Scrolling Calendars One Month at a Time With West or East
  1697. ScrollCalendars:
  1698.             OtherCalendars = Yes
  1699.             ScrollingCalendars = Yes
  1700.             '---------------------------------------------------------------
  1701.             '  Get Current Calendar Value and Set Day to First of the Month
  1702.             CalendarYear = VAL(MID$(CalendarDate$, N1, 4))
  1703.             CalendarMonth = VAL(MID$(CalendarDate$, 5, N2))
  1704.             '---------------------------------------------------------------
  1705.             '  Test if Later (Right arrow or 6) or earlier (Left arrow or 4)
  1706.             IF InString(CHR$(West) + "4", RIGHT$(Keystroke$, N1)) THEN
  1707.                 '----------------------------------------------------------
  1708.                 '  Left arrow means one month earlier
  1709.                 CalendarMonth = CalendarMonth - N1
  1710.                 IF CalendarMonth = N0 THEN
  1711.                     CalendarMonth = 12
  1712.                     CalendarYear = CalendarYear - N1
  1713.                     IF CalendarYear < N0 THEN CalendarYear = 9999
  1714.                 END IF
  1715.               ELSE
  1716.                 '----------------------------------------------------------
  1717.                 '  Right arrow means one month later
  1718.                 CalendarMonth = CalendarMonth + N1
  1719.                 IF CalendarMonth = 13 THEN
  1720.                     CalendarMonth = N1
  1721.                     CalendarYear = CalendarYear + N1
  1722.                     IF CalendarYear > 9999 THEN CalendarYear = N0
  1723.                 END IF
  1724.             END IF
  1725.             '---------------------------------------------------------------
  1726.             '  Now Put the CalendarDate Back Together and Generate Calendars
  1727.             CALL YearAdjust(CalendarYear, AdjustedYear$)
  1728.             CalendarDate$ = ZeroFill$(AdjustedYear$ + _
  1729.                 RIGHT$(STR$(CalendarMonth), N2) + "01")
  1730.             GOTO DateSpecific
  1731.         '--------------------------------------------------------------------
  1732.         CASE 20                       ' 8 for North
  1733.             GOTO ScrollNotesBack
  1734.         '--------------------------------------------------------------------
  1735.         CASE 21                       ' 2 for South
  1736.             GOTO ScrollNotesFore
  1737.         '--------------------------------------------------------------------
  1738.         CASE 22                  ' 9 for PgUp
  1739.             GOTO ScrollEventsFore
  1740.         '--------------------------------------------------------------------
  1741.         CASE 23                       ' 3 for PgDn
  1742.             GOTO ScrollEventsBack
  1743.         '--------------------------------------------------------------------
  1744.         CASE 24                        '  Escape Goes Back To Main Menu (Esc)
  1745.             Menu1 = MainMenuLastEntry
  1746.             ClockScreen = No
  1747.             CALL ClearScreenNormal(N1)
  1748.             EditPagesize = 20
  1749.             MenuSingleLine = No
  1750.             OnScreen = No
  1751.             CALL ClearOverdueTable
  1752.             GOTO MainMenuEntry
  1753.         '--------------------------------------------------------------------
  1754.         CASE ELSE                     ' Other Length One Keys
  1755.             GOTO BadKey
  1756.         '--------------------------------------------------------------------
  1757.     END SELECT
  1758.     GOTO EndOfKeys                          ' Normal One-Length Key Exit
  1759.     '=========================================================================
  1760.     '   Length Two Keys--Scroll Events/Notes/Calendars, Delete Overdue,DOS,DOS
  1761.     '           PgUp,PgDn,North,South,Del,F3,F4,F5,End,East,West,F6,F7
  1762.     '=========================================================================
  1763. TwoByteKey:
  1764.     SELECT CASE InString(CHR$(PgUp) + CHR$(PgDn) + CHR$(North) + _
  1765.          CHR$(South) + CHR$(Del) + CHR$(F3) + CHR$(F4) + CHR$(F5) + _
  1766.          CHR$(EndKey) + CHR$(East) + CHR$(West) + CHR$(F6) + _
  1767.          CHR$(F7), RIGHT$(Keystroke$, N1))
  1768.         '--------------------------------------------------------------------
  1769.         CASE 1                        '  PgUp Previous Event Window
  1770.             '     Scroll Events Backwards Footer Minus Notes Minus Overdue
  1771. ScrollEventsFore:
  1772.             IF CurrentEvent = N1 OR NOT ApptFile THEN GOTO BadKey
  1773.             FooterAction$ = "e"
  1774.             RedisplayNotesEvents = Yes
  1775.             IF CurrentEvent <= (FooterSize - NoteSize - OverdueCount) THEN
  1776.                 CurrentEvent = N1
  1777.               ELSE
  1778.                 CurrentEvent = CurrentEvent - _
  1779.                     (FooterSize - NoteSize - OverdueCount)
  1780.             END IF
  1781.         '--------------------------------------------------------------------
  1782.         CASE 2                        '  PgUp Previous Event Window
  1783.             '  Scroll Events Forwards Footer Size Minus Notes Minus Overdue
  1784. ScrollEventsBack:
  1785.             IF NOT ApptFile THEN GOTO BadKey
  1786.             FooterAction$ = "e"
  1787.             RedisplayNotesEvents = Yes
  1788.             IF (CurrentEvent + N2 * _
  1789.                (FooterSize - NoteSize - OverdueCount)) <= _
  1790.                 NumberofEvents + N1                        THEN
  1791.                 CurrentEvent = CurrentEvent + _
  1792.                     (FooterSize - NoteSize - OverdueCount)
  1793.               ELSE
  1794.                 CurrentEvent = NumberofEvents + N1 - _
  1795.                     (FooterSize - NoteSize - OverdueCount)
  1796.                 CALL MinorBeeper
  1797.             END IF
  1798.         '--------------------------------------------------------------------
  1799.         CASE 3                        '  North Previous Note Window
  1800.             '     Scroll Notes Backwards Note Size
  1801. ScrollNotesBack:
  1802.             IF NoteSize = N0 OR CurrentNote = N1 OR _
  1803.                NOT ApptFile THEN GOTO BadKey
  1804.                 FooterAction$ = False$
  1805.                 RedisplayNotesEvents = Yes
  1806.                 IF CurrentNote <= NoteSize THEN
  1807.                     CurrentNote = N1
  1808.                   ELSE
  1809.                     CurrentNote = CurrentNote - NoteSize
  1810.                 END IF
  1811.         '--------------------------------------------------------------------
  1812.         CASE 4                        ' South for Next Note Window
  1813.             '     Scroll Notes Forwards Note Size (south)
  1814. ScrollNotesFore:
  1815.             IF NoteSize = N0 OR NOT ApptFile THEN GOTO BadKey
  1816.                 FooterAction$ = False$
  1817.                 RedisplayNotesEvents = Yes
  1818.                 IF (CurrentNote + N2 * (NoteSize)) <= _
  1819.                         NumberofNotes + N1 THEN
  1820.                     CurrentNote = CurrentNote + NoteSize
  1821.                   ELSE
  1822.                     CurrentNote = NumberofNotes + N1 - NoteSize
  1823.                     CALL MinorBeeper
  1824.                 END IF
  1825.         '--------------------------------------------------------------------
  1826.         CASE 5                        '  Del for Clear Overdue Events
  1827.             '     Clear Overdue Event From Display If There
  1828. DelOverdue:
  1829.             IF NOT ApptFile OR OverdueCount = N0 THEN GOTO BadKey
  1830.                 RedisplayNotesEvents = Yes
  1831.                 RefreshInstructions = Yes
  1832.                 CALL ClearOverdueTable
  1833.                 TimerSave! = TIMER
  1834.                 CALL PrintCalendar
  1835.         '--------------------------------------------------------------------
  1836.         CASE 6                        '  F3 for On-Screen Events
  1837.             '     On-Screen Events (F3) -- Blocks of 4
  1838.             IF NOT ApptFile THEN GOTO BadKey
  1839.                 ClockScreen = Yes
  1840.                 OnEditPage = No
  1841.                 OnScreenFirst = Yes
  1842.                 OnScreen = Yes
  1843.                 Menu1 = MainMenuUse
  1844.                 EditPagesize = 4
  1845.                 WhichEvent = N1 + _
  1846.                     EditPagesize * (CurrentEvent - N1) \ EditPagesize
  1847.                 EventPageCounter = (WhichEvent - N1) \ EditPagesize
  1848.                 GOSUB HelpPromptKill
  1849.                 GOTO EventEditStart
  1850.         '--------------------------------------------------------------------
  1851.         CASE 7                        ' F4 for On-Screen Notes
  1852.             '     On-Screen Notes (F4) -- Blocks of 4
  1853.             IF NOT ApptFile THEN GOTO BadKey
  1854.                 CurrentNote = N1 + _
  1855.                     EditPagesize * (CurrentNote - N1) \ EditPagesize
  1856.                 ClockScreen = Yes
  1857.                 OnEditPage = No
  1858.                 OnScreenFirst = Yes
  1859.                 OnScreen = Yes
  1860.                 Menu1 = MainMenuUse
  1861.                 EditPagesize = 4
  1862.                 GOSUB HelpPromptKill
  1863.                 CALL NotesHistory("N")
  1864.         '--------------------------------------------------------------------
  1865.         CASE 8                        ' F5 for Pop-Back
  1866.             '     Instruction Pop-Back for 10 Seconds or Key Pressed (F5)
  1867.             IF NOT ApptFile OR FooterSize < N6 THEN GOTO BadKey
  1868.                 FooterRecall = Yes
  1869.                 CALL Instructions                  'Give Instructions
  1870.                 PopTimerStart! = FIX(TIMER)        'Set 10-Second Timer
  1871.                 PopTimerNow! = PopTimerStart!
  1872.         '--------------------------------------------------------------------
  1873.         CASE 9                        ' End for Page Eject
  1874.             '     Page Eject Printing Event File (End)
  1875. PrinterPage:
  1876.             IF NOT ApptFile THEN GOTO BadKey
  1877.             CALL InitPrinter
  1878.             CALL PageEject
  1879.             IF LprintTerminate THEN 
  1880.                 LprintTerminate = No
  1881.             END IF
  1882.         '--------------------------------------------------------------------
  1883.         CASE 10, 11                   ' East/West Arrows for Scrolling
  1884.             GOTO ScrollCalendars
  1885.         '--------------------------------------------------------------------
  1886.         CASE 12                       ' F6 For DOS Shell
  1887.             CALL DOSShell(N1)
  1888.             GOTO ClockInitialize
  1889.         '--------------------------------------------------------------------
  1890.         CASE 13                       ' F7 For DOS Prestored Command
  1891.             CALL DOSShell(N2)
  1892.             GOTO ClockInitialize
  1893.         '--------------------------------------------------------------------
  1894.         CASE ELSE                     '  Other Length Two Keystrokes
  1895.         GOTO BadKey
  1896.         '--------------------------------------------------------------------
  1897.     END SELECT
  1898.     GOTO EndOfKeys                          ' Normal Two-Length Key Exit
  1899.     '=========================================================================
  1900.     '   Blank F5 Help if needed
  1901. HelpPromptKill:
  1902.     IF FooterSize >= N6 THEN CALL ShowIt(N3, F5HelpRow, N1, Blank8$)
  1903.     RETURN
  1904.     '-------------------------------------------------------------------------
  1905.     '     Invalid Keystroke or Nothing To Do On Valid One
  1906.     '-------------------------------------------------------------------------
  1907. BadKey:
  1908.     CALL MinorBeeper
  1909.     '=========================================================================
  1910.     '   Keystroke Processing Finished, Refresh Events And Start Loop Again
  1911.     '=========================================================================
  1912.     '     Refresh Events/Notes and Instructions If Required
  1913. EndOfKeys:
  1914.     IF ApptFile AND RedisplayNotesEvents THEN
  1915.         CALL RefreshEventsNotes
  1916.         IF FromOverduePage THEN 
  1917.             GOTO ClockInitialize
  1918.         END IF
  1919.     END IF
  1920.     IF RefreshInstructions THEN CALL Instructions
  1921.     '-------------------------------------------------------------------------
  1922.     '     Do the Sound Indicator If Necessary
  1923.     IF RedisplayNotesEvents OR TimeBlock THEN GOSUB SoundDisplay
  1924.     '-------------------------------------------------------------------------
  1925.     OnEditPage = No
  1926.     ClockScreen = Yes
  1927.     RedisplayNotesEvents = No
  1928.     TimeBlock = No
  1929.     ScrollingCalendars = No
  1930.     IF NOT InterruptedLoop THEN WholeClock = No
  1931.     IF SrAutoPopDown AND (AutoMode$ = True$) AND NOT SrAutoPopDownHappened _
  1932.             AND NOT SrAutoPopDownReady                             THEN
  1933.         SrAutoPopDownReady = Yes
  1934.     END IF
  1935.     '=========================================================================
  1936.     '     Start The Timing Loop Over Again
  1937.     GOTO TimingLoopStart
  1938.     END SUB
  1939.     '=========================================================================
  1940.     '  This Procedure Exits ONLY Through a Trapped Error and Always Returns
  1941.     '   (except in primitive mode, which ends in the main program)
  1942.     '=========================================================================
  1943.     '========================  END OF CAL2.BAS  =============================
  1944.     '========================================================================
  1945.